#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


# Program 1.2.3 - Quadratic formula

Syntax:
python quadratic.py -3.0 2.0


Notes:
float(sys.argv[1]) == Double.parseDouble(args[1])

sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

math is a required import here for the sqrt() function.
https://docs.python.org/2/library/math.html

'''

import sys
import math


def main():
    ''' Quadratic formula calculation '''

    arg1 = float(sys.argv[1])
    arg2 = float(sys.argv[2])
    discriminant = arg1 * arg1 - 4.0 * arg2
    solution = math.sqrt(discriminant)
    print 'First root   :', ((-arg1 + solution) / 2.0)
    print 'Second root  :', ((-arg1 - solution) / 2.0)


if __name__ == '__main__':
    main()
